/**
 * author: Hanflyee  flyee1980@163.com
 * vision: v1.0
 * data: 2009-7-9
 */
package com.flyee.communicate.scene{
	 
	import com.flyee.communicate.Communicate;
	import com.flyee.io.Config;
	import com.flyee.io.webservice.RemoteBean;
	import com.flyee.io.webservice.RemoteService;
	import com.flyee.model.Component;
	import com.flyee.model.Scene;
	import com.flyee.service.pool.ObjectCollection;
	import com.flyee.utils.MyLog;
	import com.flyee.utils.Obsevable;
	
	/**
	 * 取得场景 指令 
	 */
	public class GetSceneCommunicate extends Obsevable implements Communicate{
				
		public function GetSceneCommunicate(){
		}

		public function request(...args):void{
			//AMF方式请求服务器
			var remoteBean : RemoteBean = RemoteService.getInstance().getRemoteBean("sceneFlexService", this);
			remoteBean.getSceneComponent(args[0]);
		}
		
		public function response(...args):void{
			//处理服务器返回数据
			ObjectCollection.currentScene = args[0] as Scene;
			ObjectCollection.currentScene.bgUrl = Config.getInstance().STATIC_SERVER + ObjectCollection.currentScene.bgUrl;
			
			for each(var component : Component in ObjectCollection.currentScene.componentList){
				component.url = Config.getInstance().STATIC_SERVER + component.url;	
				ObjectCollection.componentMap.put(component.mid, component);
			}
			//通知观察者
			setChanged();
			notifyObsevers("loadScene", ObjectCollection.currentScene, ObjectCollection.componentMap);
//			callbackFn.call(null, ObjectCollection.currentScene, ObjectCollection.componentMap);
		}
		
	}
}